<?php

function view_agenda($config,$param) {
    view_header_up($config,$param);
    //
    ?>
    <link rel="stylesheet" href="<? echo $config['css_url']; ?>jquery-ui-timepicker-addon.css">
    <link rel="stylesheet" href="<? echo $config['css_url']; ?>ui-lightness/jquery-ui-1.10.2.custom.min.css">
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
    <script type="text/javascript" src="<? echo $config['js_url']; ?>jquery-ui-timepicker-addon.js"></script>
    <title>Idebeda-Agenda</title>
    <?
    //
    view_header_bottom($config,$param);
    ?>
    <h2>Agenda</h2>
    <script type="text/javascript">
		$(function() {
			$('#tglMulai').datetimepicker({dateFormat: "dd-mm-yy"});
			$('#tglSelesai').datetimepicker({dateFormat: "dd-mm-yy"});
		});
		function validateEmpty(fld) {
			var error = "";
		 
			if (fld.value.length == 0) {
				fld.style.background = 'Yellow'; 
				error = "1";
			} else {
				fld.style.background = 'White';
			}
			return error;  
		}
		function validateForm(theForm) {
			var reason = "";
			
			  reason += validateEmpty(theForm.tugas);
			  reason += validateEmpty(theForm.tempat);
			  reason += validateEmpty(theForm.lifeline);
			  reason += validateEmpty(theForm.deadline);
				  
			  if (reason != "") {
				alert("Perhatian, isi yang masih kosong.");
				return false;
			  }

			  return true;
			}
		function show_login_status(network, status){
		if (status)
			{
				$('#logcal').show();
				//alert("Logged in to " + network);
			}else{
				$('#logmail').show();
				//alert("Not logged in to " + network);
			}
		}

	</script>
	<?
	if (isset($_SESSION['addsucc'])) {
        echo '<div class="success alert">'.$_SESSION['addsucc'].'</div>';
        unset($_SESSION['addsucc']);
    }
    if (isset($_SESSION['sentsucc'])) {
        echo '<div class="success alert">'.$_SESSION['sentsucc'].'</div>';
        unset($_SESSION['sentsucc']);
    }
    if (isset($_SESSION['addfail'])) {
        echo '<div class="warning alert">'.$_SESSION['addfail'].'</div>';
        unset($_SESSION['addfail']);
    }
    ?>    
	<img style="display:none;"
	onload="show_login_status('Google', true)"
	onerror="show_login_status('Google', false)"
	src="https://accounts.google.com/CheckCookie?continue=https%3A%2F%2Fwww.google.com%2Fintl%2Fen%2Fimages%2Flogos%2Faccounts_logo.png&followup=https%3A%2F%2Fwww.google.com%2Fintl%2Fen%2Fimages%2Flogos%2Faccounts_logo.png&chtml=LoginDoneHtml&checkedDomains=youtube&checkConnection=youtube%3A291%3A1"
	/>
	<div id="logmail" style="display:none"><h3>Login Google dahulu <a href="https://accounts.google.com/Login?service=profiles">disini</a>, kalau ingin lihat agenda</h3></div>
    <div id="logcal" style="display:none"><iframe src="https://www.google.com/calendar/embed?showPrint=0&amp;showCalendars=0&amp;showTz=0&amp;height=600&amp;wkst=1&amp;bgcolor=%23FFFFFF&amp;src=agp44d2mbjilf2g0ts10c1roeg%40group.calendar.google.com&amp;color=%232F6309&amp;ctz=Asia%2FJakarta" style=" border-width:0 " width="620" height="600" frameborder="0" scrolling="no"></iframe></div>
    <?php
		if (isset($_SESSION['logged']))
			if ($_SESSION['logged']['role']<3){
    ?>
    <h3>Tambah Agenda</h3>
    <div>
		<form action="" method="post" onsubmit="return validateForm(this)">
			<ul>
				<li class="field">
					<label class="inline" for="tugas">Nama Agenda</label>
					<input class="text input" autocomplete="off" id="tugas" name="tugas" type="text" placeholder="Kerjaan" />
				</li>
				<li class="field">
					<label class="inline" for="tempat">Tempat</label>
					<input class="wide text input" id="tempat" name="tempat" type="text" placeholder="nama tempat" />
				</li>
				<li class="field">
					<label class="inline" for="tglMulai">Kick Off</label>
					<input class="wide text input" id="tglMulai" name="lifeline" type="text" placeholder="klik dulu gan" />
					<div id="inlineDatepicker"></div>
				</li>
				<li class="field">
					<label class="inline" for="tglSelesai">Deadline</label>
					<input class="wide text input" id="tglSelesai" name="deadline" type="text" placeholder="klik dulu gan" />
					<div id="inlineDatepicker"></div>
				</li>
				<li class="field">
					<label class="inline" for="ket">Keterangan</label>
					<textarea class="input textarea" rows="5" placeholder="Textarea" name="ket"></textarea>
				</li>
				<div class="medium primary btn"><input type="submit" name="kirim" value="Tambah" /></div>
			</ul>
		</form>
	</div>
	<?php
		}
    ?>
<?
	view_footer($config,$param);
}

?>
